﻿<sdk:Page	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:InsuranceAdjuster.Controls"            
	mc:Ignorable="d"
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"	
            xmlns:common="clr-namespace:Papa.Common;assembly=Papa.Common"
     xmlns:helpers="clr-namespace:InsuranceAdjuster.Helpers"
    x:Class="InsuranceAdjuster.Views.DamageView" 
	Title="DamageView Page"
    d:DesignWidth="1280" d:DesignHeight="600"  
	FontSize="18.667" FontFamily="Segoe"
    DataContext="{Binding Claim, Source={StaticResource Locator}}" 
    Width="1000" Height="640"
>
    <sdk:Page.Resources>
        <common:ByteArrayToImageConverter x:Name="ByteArrayToImageConverter" />
    </sdk:Page.Resources>

    <Grid x:Name="LayoutRoot" Background="White" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Height="140">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0" Background="#888888" >
                <TextBlock x:Name="infotb" Grid.Column="0" Text="Click 'Add Photos' or insert a USB drive to add photographs." FontSize="16" Foreground="White" TextWrapping="Wrap" FontStyle="Italic" Margin="25,10,6,10"
                           Visibility="{Binding DamagePhotoPromptVisibility}"/>
                <Border Grid.Column="0" Margin="20,5,20,5" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="1"
                                  Visibility="{Binding DamagePhotosVisibility}"  >
                    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" Height="130"> 
                    <ItemsControl Name="lstDamageItems"   HorizontalAlignment="Stretch" Margin="5"
                                  ItemsSource="{Binding Path=SelectedClaim.ClaimDamages}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate >
                                <HyperlinkButton Click="HyperlinkButton_Click">
                                    <HyperlinkButton.Content>
                                        <Border BorderBrush="Black" BorderThickness="1" Height="100"  Background="#FF595959" Margin="5" >
                                            <Image Margin="0" VerticalAlignment="Stretch" HorizontalAlignment="Center" Source="{Binding Path=Image, Converter={StaticResource ByteArrayToImageConverter}}"/>
                                        </Border>
                                    </HyperlinkButton.Content>
                                </HyperlinkButton>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </ScrollViewer>
                </Border>
            </Grid>
            <Grid Grid.Column="1" Background="{StaticResource YellowBrush}">
                <HyperlinkButton x:Name="addPhotosButton" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" Content="Add photos" Margin="30"
                                 Command="{Binding Path=AddPhotosCommand}"/>
            </Grid>
        </Grid>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1.3*"/>
                <ColumnDefinition Width="2*"/>
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0" Background="{StaticResource YellowBrush}">
                <Viewbox HorizontalAlignment="Left">
                    <controls:PanelViewer HorizontalAlignment="Left" VerticalAlignment="Top"  Margin="20,30,20,30" SelectedPanels="{Binding Path=SelectedClaimDamage.LocationOnVehicle, Mode=TwoWay}" />
                </Viewbox>
            </Grid>
            <Grid Grid.Column="1" Margin="10,10,10,10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" Grid.ColumnSpan="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <TextBlock  HorizontalAlignment="Left" Margin="0,-5,0,0" TextWrapping="Wrap" Text="Damage Points" VerticalAlignment="Top" Style="{StaticResource TitleStyle}" d:LayoutOverrides="HorizontalAlignment"/>
                    <Button Grid.Row="4" Grid.Column="1" Content="Delete Damage Point" Height="30" Width="150" Margin="0,10,0,0" VerticalAlignment="Top" HorizontalAlignment="Right" FontSize="14" Foreground="#444444" 
                        Command="{Binding DeleteClaimDamageCommand}" CommandParameter="{Binding SelectedClaimDamage}" >
                        <Button.Template>
                            <ControlTemplate TargetType="Button">
                                <Grid Background="{StaticResource YellowBrush}">
                                    <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                </Grid>
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                
                </Grid>
                <sdk:Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Photo" Margin="0,10,20,0"/>
                <Border Grid.Row="1" Grid.Column="1"  Margin="5"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                    <Border BorderBrush="Black" BorderThickness="1" Background="#FF888888" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0" Visibility="{Binding DamagePhotoVisibility}">                        
                        <Image Margin="0"  Source="{Binding  Path=SelectedClaimDamage.Image, Converter={StaticResource ByteArrayToImageConverter}}"
                               MinHeight="300" MinWidth="400" />
                    </Border>
                </Border>
                <sdk:Label Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Description" Margin="0,10,20,0" />
                <TextBox Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" TextWrapping="Wrap" Text="{Binding Path=SelectedClaimDamage.Description}" IsEnabled="{Binding IsDamageItemSelected}" />
                <sdk:Label Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Locations" Margin="0,10,20,0" />

                <TextBox Grid.Row="3" Grid.Column="1" Margin="0,10,0,0" TextWrapping="Wrap" Text="{Binding Path=SelectedClaimDamage.LocationOnVehicle}" IsReadOnly="True" />
                
            </Grid>
        </Grid>
    </Grid>
</sdk:Page>